// pages/waiter/ordercheck/ordercheck.js
const request = require('@/utils/request.js')
const constants = require('@/utils/khyConstants.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    transportStateList: getApp().globalData.dictData['transportState'],
    dataList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const app = getApp();
      this.setData({
        order_bg:app.globalData.nginxIp+'/img/order_bg.png',
        order_bg_text:app.globalData.nginxIp+'/img/order_bg_text.png',
        waiter_text:app.globalData.nginxIp+'/img/waiter_text.png',
        daofu:app.globalData.nginxIp+'/img/daofu.png',
      })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getPageData()
  },

  getPageData() {
    let user = getApp().getUserInfo()
    let param = {transportState: '2'}
    if (user.stationId) {
      param.endStation = user.stationId
    }
    
    request.get('/UserController/getTransInfoByTransportState', param).then(res => {
      if (res.data.code == constants.resultSuccessCode
        && res.data.result) {
        let data = res.data.result || []
        this.setData({
          dataList: data,
        })
      }
    })
  },

  delivery(e) {
    let transinfo = e.currentTarget.dataset.transinfo
    if (transinfo) {
      getApp().globalData.pageData[constants.page_delivery] = transinfo
      wx.navigateTo({
        url: '/pages/waiter/delivery/delivery',
      })
    }
    
  },
  record() {
    wx.navigateTo({
      url: '/pages/waiter/ordercheckHis/ordercheckHis',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})